package com.linwen.javase.desgin_pattern.BigTalkDesignPattenJAVACode._14备忘录模式._1基本代码;

public class Test {
	
	public static void main(String[] args){

        //Originator初始状态，状态属性为"On"
        Originator o = new Originator();
        o.setState("On");
        o.show();

        Caretaker c = new Caretaker();
        //保存状态时，由于有了很好的封装，可以隐藏Originator的实现细节
        c.setMemento(o.createMemento());

        //Originator改变了状态属性为"Off"
        o.setState("Off");
        o.show();

        //恢复原初始状态
        o.recoveryMemento(c.getMemento());
        o.show();
	}
}




